package cn.iocoder.yudao.module.member.dal.mysql.scoretype;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.member.controller.admin.scoretype.vo.ScoreTypeExportReqVO;
import cn.iocoder.yudao.module.member.controller.admin.scoretype.vo.ScoreTypePageReqVO;
import cn.iocoder.yudao.module.member.dal.dataobject.scoretype.ScoreTypeDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * 积分用途 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface ScoreTypeMapper extends BaseMapperX<ScoreTypeDO> {

    default PageResult<ScoreTypeDO> selectPage(ScoreTypePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ScoreTypeDO>()
                .eqIfPresent(ScoreTypeDO::getCode, reqVO.getCode())
                .likeIfPresent(ScoreTypeDO::getName, reqVO.getName())
                .eqIfPresent(ScoreTypeDO::getScoreType, reqVO.getScoreType())
                .eqIfPresent(ScoreTypeDO::getRemark, reqVO.getRemark())
                .betweenIfPresent(ScoreTypeDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(ScoreTypeDO::getId));
    }

    default List<ScoreTypeDO> selectList(ScoreTypeExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<ScoreTypeDO>()
                .eqIfPresent(ScoreTypeDO::getCode, reqVO.getCode())
                .likeIfPresent(ScoreTypeDO::getName, reqVO.getName())
                .eqIfPresent(ScoreTypeDO::getScoreType, reqVO.getScoreType())
                .eqIfPresent(ScoreTypeDO::getRemark, reqVO.getRemark())
                .betweenIfPresent(ScoreTypeDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(ScoreTypeDO::getId));
    }

}
